package easy

func SortArrayByParityII(nums []int) []int {
	n := len(nums)
	res := make([]int, n)
	slow, fast := 0, 1
	for _, num := range nums {
		if num%2 == 0 {
			res[slow] = num
			slow += 2
		} else {
			res[fast] = num
			fast += 2
		}
	}
	return res
}
